package com.yanqu.road.server.manger.activity.recycle;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.activity.ActivityItemRecycleData;
import com.yanqu.road.entity.activity.doublespring.DoubleSpringActivityConfig;
import com.yanqu.road.entity.activity.springdraw.config.SpringDrawConfig;
import com.yanqu.road.entity.config.goods.GoodsInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.entity.enums.eMailType;
import com.yanqu.road.entity.player.UserBagItem;
import com.yanqu.road.server.logic.mail.MailManager;
import com.yanqu.road.server.manger.MultipleLanguageMgr;
import com.yanqu.road.server.manger.ServerLanguageMgr;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.activity.doublespring.DoubleSpringActivityMgr;
import com.yanqu.road.server.manger.activity.springdraw.SpringDrawMgr;
import com.yanqu.road.server.manger.config.GoodsMgr;
import com.yanqu.road.server.manger.player.UserMgr;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;

import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.List;

public class SpringDrawRecycleStrategy extends AbstractItemRecycleStrategy {

    @Override
    public void markNeedRecycleItem() {
        List<ActivityInfo> activityList = NormalActivityMgr.getOpenActivityInfoList(eActivityType.SpringDraw.getValue());
        for (ActivityInfo activityInfo : activityList) {
            if (activityInfo != null) {
                //回收时间
                long recycleTime = activityInfo.getEndShowTime() * 1000L + 600 * 1000;
                //回收的道具ID
                SpringDrawConfig config = SpringDrawMgr.getActivityConfig(activityInfo.getActivityId());
                if (config != null) {
                    int itemId = config.getSPRING_DRAW_ITEM_ID();
                    int scoreItemId = config.getEXCHANGE_SCORE_ITEM_ID();
                    List<String> paramList = new ArrayList<>();
                    paramList.add(String.valueOf(itemId));
                    paramList.add(String.valueOf(scoreItemId));
                    paramList.add("0");//itemId道具param第几个参数：换成多少个积分
                    paramList.add(activityInfo.getActivityName());
                    ActivityItemRecycleMgr.addRecycleItemData(itemId, activityType, 0, recycleTime, paramList);
                }
            }
        }
    }

    @Override
    protected void initActivityType() {
        activityType = eActivityType.SpringDraw.getValue();
    }

    @Override
    protected void doRecycle(long userId, ActivityItemRecycleData data) {
        item2Score(userId, data);
//        int itemId = data.getItemId();
//        UserBagItem userBagItem = getUserBagItem(userId, itemId);
//        if (userBagItem != null && userBagItem.getNum() > 0) {
//            this.removeItem(userBagItem);
//        }
    }

    @Override
    public boolean isActivityRunning() {
        return false;
    }
}
